<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="admin/_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="stylesheet" href="../../static/semantis-ui/semantic.min.css">
    <script type="text/javascript" src="../../static/semantis-ui/jquery-3.6.0.js"></script>
    <script src="../../static/semantis-ui/semantic.min.js"></script>
    <link rel="stylesheet" href="../../static/css/me.css">
    <title>管理后台</title>
</head>
<body>
<!--导航-->
<!--segment反转 inverted平铺 导航栏-->
<nav class="ui segment inverted attached segment me-padded-tb-mini bg">
    <!--放在一个container中-->
    <div class="ui container ">
        <!--里面的菜单   stackable适应手机-->
        <div class="ui inverted stackable menu bg">
            <h2 class="ui teal header item ">HJ&nbsp&nbspblog</h2>
            <a href="#" th:href="@{/admin/blogs}" class="m-item item m-mobile-hide"><i class="m-margin-tb-menu icon home"></i>首页</a>
            <a href="#" th:href="@{/admin/types}" class="m-item item m-mobile-hide"><i class="m-margin-tb-menu folder open outline icon"></i>分类</a>
            <a href="#" th:href="@{/admin/tags}"  class="m-item item m-mobile-hide"><i class="m-margin-tb-menu edit outline icon"></i>标签</a>
            <div class="right menu">
                <div class="ui dropdown item"  th:replace="admin/_fragments :: content">
                    <div class="text">
                        <img src="../../static/image/小.png" alt="" class="ui avatar image">
                        王锡豪
                    </div>
                    <i class="dropdown icon"></i>
                    <div class="menu">
                        <a href="#" class="item">注销</a>
                    </div>


                </div>
            </div>

        </div>
    </div>
    <!--三条杠 更多按钮-->
    <a href="#" class="ui icon button menu toggle m-right-top bg white-font m-mobile-show">
        <i class="sidebar icon"></i>
    </a>
</nav>
<div class="ui attached pointing menu">
    <div class="ui container">
        <div class="right menu">

            <a href="#" class="item">发布</a>
            <a href="#" class="active item">列表</a>

        </div>

    </div>
</div>


<!--中间-->
<div class="m-padded-d-mass">
    <div class="m-container-small m-padded-tb-big">
        <div class="ui container">
            <!--header -->
            <!--<form action="#" class="ui segment secondary form" method="post">-->
            <div class="ui segment secondary form" >
                <!--隐含域-->
                <input type="hidden" name="page">
                <div class="inline fields">
                    <div class="field">
                        <input type="text" name="title" placeholder="标题">
                    </div>
                    <div class="field">
                        <div class="ui selection type dropdown">
                            <input type="hidden" name="typeId"><i class="dropdown icon"></i>
                            <div class="default text">分类</div>
                            <div class="menu">
                                <!--th:each="type : ${types}"循环拿到types中的值-->
                                <div th:each="type : ${types}" class="item" data-value="1" th:data-value="${type.id}" th:text="${type.name}">错误日志</div>
                                <!--<div class="item" data-value="2">开发者手册</div>-->
                            </div>
                        </div>
                        <button id="clear-btn" class="ui button">点击清空</button>

                    </div>
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" id="recommend" name="recommend">
                            <label for="recommend">推荐</label>
                        </div>
                    </div>
                    <div class=" field">
                        <button type="button" id="search-btn" class="ui mini teal basic button"><i class="search icon"></i>搜索</button>
                    </div>

                </div>
            </div>

            <div id="table-container">

                <!--表格  celled网格  compact表格紧缩-->
                <table th:fragment="blogList" class="ui compact teal table" >
                    <thead>
                    <tr>
                        <th></th>
                        <th>标题</th>
                        <th>类型</th>
                        <th>推荐</th>
                        <th>状态</th>
                        <th>更新时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <!--th:each="blog,iterStat : ${page.content}"  从page.content拿到blog和iterStat  iterStat一个排序工具  blog里面有定义的属性  -->
                    <tr th:each="blog,iterStat : ${page.content}">
                        <td th:text="${iterStat.count}">1</td>
                        <td th:text="${blog.title}">刻意练习清单</td>
                        <td th:text="${blog.type.name}">认知升级</td>
                        <td th:text="${blog.recommend} ? '是' : '否'">是</td>
                        <td th:text="${blog.published} ? '已发布' : '草稿'">是</td>
                        <td th:text="${blog.updateTime}">2017-10-02 09:45</td>
                        <td>
                            <!--@{/admin/types/{id}/input(id=${type.id})}传值 给types-inpput页面  之后在types-inpput里面会判断-->
                            <a href="#" th:href="@{/admin/blogs/{id}/input(id=${blog.id})}" class="ui mini button">&nbsp;&nbsp;&nbsp;&nbsp;编 辑&nbsp;&nbsp;&nbsp;&nbsp;</a>
                            <a href="#" th:href="@{/admin/blogs/{id}/delete(id=${blog.id})}" class="ui button mini red" data-tooltip="确认删除吗？">&nbsp;&nbsp;&nbsp;&nbsp;删 除&nbsp;&nbsp;&nbsp;&nbsp;</a>
                        </td>
                    </tr>
                    </tbody>

                    <tfoot>
                    <tr>
                        <!--<th colspan="7">合并上面7列-->
                        <th colspan="7">
                            <div class="ui mini pagination menu" th:if="${page.totalPages} > 1" >
                                <!--为了只刷新表内数据  使用方法-->
                                <a onclick="page(this)" th:attr="data-page=${page.number}-1" class="item" th:unless ="${page.first }">上一页</a>
                                <a onclick="page(this)" th:attr="data-page=${page.number}+1" class="item" th:unless ="${page.last}">下一页</a>
                            </div>
                            <a href="#" th:href="@{/admin/blogs/input}" class="ui mini right floated teal basic button">新增</a></th>
                    </tr>
                    </tfoot>
                </table>


                <div class="ui success message" th:unless="${#strings.isEmpty(message)}">
                    <i class="close icon"></i>
                    <div class="header">提示:</div>
                    <p th:text="${message}">恭喜操作成功！</p>
                </div>


            </div>


        </div>
    </div>


    <br/>
</div>

<!--底部      m-padded-d-mass间隔-->
<footer class="ui segment inverted vertical segment m-padded-d-mass bg">
    <!--container容器 center aligned居中-->
    <div class="ui center aligned container bg">
        <!--grid会把一些布局分为12列  devided加线 -->
        <div class="ui inverted divided grid bg">
            <div class="three wide column m-opacity-mini m-text-space m-text-thin m-text-lined">
                <div class="ui inverted link list bg">
                    <img src="./static/image/wo.jpg" alt="" class="ui rounded image" style="width:110px">

                </div>
            </div>
            <div class="three wide column m-opacity-mini m-text-space m-text-thin m-text-lined">
                <h4 class="ui inverted header">最新博客</h4>
                <div class="ui inverted link list ">
                    <a href="#" class="item">会飞的羊</a>
                    <a href="#" class="item">会飞的羊</a>
                    <a href="#" class="item">会飞的羊</a>
                </div>
            </div>
            <div class="three wide column m-opacity-mini m-text-space m-text-thin m-text-lined">
                <h4 class="ui inverted header">联系我吖</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">QQ:822021336</a>
                    <a href="#" class="item">邮箱：xihao.luck@qq.com</a>
                    <a href="#" class="item"></a>
                </div>
            </div>
            <div class="seven wide column">
                <h4 class="ui inverted header m-opacity-mini m-text-space m-text-thin m-text-lined">最新博客</h4>
                <p class="m-opacity-mini m-text-space m-text-thin m-text-lined">
                    这是我的个人博客，用于记录我在网上收集的文章，自己的代码笔记，和优秀的文案等等。欢迎大家关注！</p>
            </div>
        </div>
        <div class="ui inverted section divider m-opacity-mini m-text-space m-text-thin m-text-lined "></div>
        <p class="m-opacity-mini m-text-space m-text-thin m-text-lined">Copyright © 2021-2022 会飞的羊 </p>
    </div>

</footer>


<!--jquery-->

<script>
    // <!--点击.menu.toggle按钮加入m-mobile-hide样式-->
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide')
    });

    $('.ui.dropdown')
        .dropdown();

    function page(obj) {
        $("[name = 'page']").val($(obj).data("page"));
        loaddata();
    };


    //搜索
    $("#search-btn").click(function () {
        $("[name = 'page']").val(0);
        loaddata();
    });

    //使用ajax动态获取数据 从/*[[@{/admin/blogs/search}]]*/
    function loaddata() {
        $("#table-container").load(/*[[@{/admin/blogs/search}]]*/"/admin/blogs/search", {
            title : $("[name='title']").val(),
            typeId : $("[name='typeId']").val(),
            recommend : $("[name='recommend']").prop('checked'),
            page : $("[name='page']").val()
        });
    };

    //    关闭提示框
    $('.message .close')
        .on('click',function () {
            $(this)
                .closest('.message')
                .transition('fade');
        });

//    清理框内容
    $("#clear-btn")
        .on('click',function () {
            $('.ui.type.dropdown')
                .dropdown('clear');
        });

</script>
</body>
</html>